//
//  LFBStartCollectionViewCell.m
//  loveFreshBeen
//
//  Created by Feng on 2017/7/9.
//  Copyright © 2017年 feng. All rights reserved.
//

#import "LFBStartCollectionViewCell.h"
#import "UIColor+Addition.h"

@interface LFBStartCollectionViewCell ()

@property(nonatomic,weak) UIImageView *imageView;

@end

@implementation LFBStartCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
    self.imageView = imageView;
    
    [self.contentView addSubview:imageView];
    
    UIButton *startButton = [[UIButton alloc] initWithFrame:CGRectMake(0,0,([UIScreen mainScreen].bounds.size.width /  2) - 40, 600-40)];
    startButton.center = CGPointMake([UIScreen mainScreen].bounds.size.width / 2, 600);
    [startButton setTitle:@"立即体验" forState:UIControlStateNormal];
    [startButton setBackgroundColor:[UIColor colorWithHex:0xFACB3D alpha:1]];
    [startButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.startButton = startButton;
    [self.contentView addSubview:startButton];
    
    //添加按钮点击事件
    [startButton addTarget:self action:@selector(startButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)startButtonAction:(UIButton *)button
{
    //发送通知
    [[NSNotificationCenter defaultCenter] postNotificationName:@"LFBStartButtonActionNotification" object:self];
    
    if(self.startButtonBlock)
    {
        self.startButtonBlock();
    }
}

- (void)setModel:(LFBStartModel *)model
{
    _model = model;
    self.imageView.image = [UIImage imageNamed:model.imageName];
}

@end
